package com.moyq5.mvc.maker.test.bean.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import com.moyq5.mvc.maker.test.bean.enums.ChannelMerchAuditStatus;
import com.moyq5.mvc.maker.test.bean.enums.ChannelMerchStatus;
import com.moyq5.mvc.maker.test.bean.enums.ChannelMerchType;

/**
 * 渠道商户信息
 * @author Moyq5
 * @date 2017年12月12日
 */
@Entity
@Table(name = "tra_channel_merch",indexes={@Index(columnList="pay_tmsl")})
@DynamicUpdate
public class TraChannelMerch implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// 渠道商户ID
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "native")@GenericGenerator(name = "native", strategy = "native")
    @Column(name = "channel_merch_id")
	private Long channelMerchId;
	/**
	 * 授权代理商，指定的代理商有权限将该渠道商户分配给其下商户。
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "agent_id")
	private Agent agent;
	/**
	 * 渠道
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "channel_id", nullable = false)
	private TraChannel channel;
	/**
	 * 渠道商户名称
	 */
	@Column(name = "name", length = 60, nullable = false)
	private String name;
	/**
	 * 渠道商户号
	 */
	@Column(name = "merch_no", length = 32, nullable = false)
	private String merchNo;
	/**
	 * 渠道商户类型
	 */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "type", columnDefinition="int(1) default '0'")
	private ChannelMerchType type;
	/**
	 * 渠道商户结算商户
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "account_id", nullable = false)
	private BankAccount bankAccount;
	/**
	 * 渠道商户渠道审核状态
	 */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "audit_status", columnDefinition="int(1) default '0'")
	private ChannelMerchAuditStatus auditStatus;
	/**
	 * 渠道商户渠道审核描述
	 */
	@Column(name = "audit_desc", length = 500)
	private String auditDesc;
	/**
	 * 渠道商户审核时间
	 */
	@Column(name = "audit_time", columnDefinition="datetime")
	private Date auditTime;
	/**
	 * 渠道商户终端号
	 */
	@Column(name = "term_no", length = 30)
	private String termNo;
	/**
	 * 状态(平台控制)
	 */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "status", columnDefinition="int(1) default '0'")
	private ChannelMerchStatus status;
    /**
     * 支付类型-支付方式-结算类型-结算延时（小时）。多选。
     * 格式：[payType-payMethod-settleType-settleLazy][payType-payMethod-settleType-settleLazy]
     */
    @Column(name = "pay_tmsl", length = 200)
    private String payTmsl;
    /**
     * 描述（功能补充说明）
     */
    @Column(name = "remark", length = 300)
	private String remark;
	/**
	 * 微信公众号AppId
	 */
	@Column(name = "wx_app_id", length = 32)
	private String wxAppId;
	/**
	 * 微信公众号AppSerect
	 */
	@Column(name = "wx_app_serect", length = 32)
	private String wxAppSerect;
	/**
	 * 交易密钥（RSA或者MD5）
	 */
	@Column(name = "trans_key", length = 2000)
	private String transKey;
	/**
	 * 交易码。扩展参数，如渠道商户的收款码的qrcodeId，或者userId，或者qrcodeUrl等，渠道不一样内容或者格式不一样）
	 */
	@Column(name = "trans_code", length = 300)
	private String transCode;
	/**
	 * 交易证书文件（路径）
	 */
	@Column(name = "certificate", length = 150)
	private String certificate;
	/**
	 * 交易控制
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "confine_id")
	private TraConfine confine;
	/**
	 * 提现单笔费率，如：0.0049
	 */
	@Column(name = "remit_rate", columnDefinition = "decimal(5,4) not null default '0.0000'")
	private BigDecimal remitRate;
	/**
	 * 提现单笔提现费（元）
	 */
	@Column(name = "remit_fee", columnDefinition = "decimal(10,2) not null default '2.00'")
	private BigDecimal remitFee;
    /**
	 * 添加时间
	 */
	@Column(name = "add_time", nullable = false, columnDefinition="datetime")
	private Date addTime;
	@PrePersist
	public void prePersist() {
		if (null == addTime) {
			addTime = new Date();
		}
	}
	public Long getChannelMerchId() {
		return channelMerchId;
	}
	public void setChannelMerchId(Long channelMerchId) {
		this.channelMerchId = channelMerchId;
	}
	public TraChannel getChannel() {
		return channel;
	}
	public void setChannel(TraChannel channel) {
		this.channel = channel;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getMerchNo() {
		return merchNo;
	}
	public void setMerchNo(String merchNo) {
		this.merchNo = merchNo;
	}
	public ChannelMerchType getType() {
		return type;
	}
	public void setType(ChannelMerchType type) {
		this.type = type;
	}
	public BankAccount getBankAccount() {
		return bankAccount;
	}
	public void setBankAccount(BankAccount bankAccount) {
		this.bankAccount = bankAccount;
	}
	public ChannelMerchAuditStatus getAuditStatus() {
		return auditStatus;
	}
	public void setAuditStatus(ChannelMerchAuditStatus auditStatus) {
		this.auditStatus = auditStatus;
	}
	public String getAuditDesc() {
		return auditDesc;
	}
	public void setAuditDesc(String auditDesc) {
		this.auditDesc = auditDesc;
	}
	public Date getAuditTime() {
		return auditTime;
	}
	public void setAuditTime(Date auditTime) {
		this.auditTime = auditTime;
	}
	public String getTermNo() {
		return termNo;
	}
	public void setTermNo(String termNo) {
		this.termNo = termNo;
	}
	public ChannelMerchStatus getStatus() {
		return status;
	}
	public void setStatus(ChannelMerchStatus status) {
		this.status = status;
	}
	public String getWxAppId() {
		return wxAppId;
	}
	public void setWxAppId(String wxAppId) {
		this.wxAppId = wxAppId;
	}
	public String getWxAppSerect() {
		return wxAppSerect;
	}
	public void setWxAppSerect(String wxAppSerect) {
		this.wxAppSerect = wxAppSerect;
	}
	public String getTransKey() {
		return transKey;
	}
	public void setTransKey(String transKey) {
		this.transKey = transKey;
	}
	public Date getAddTime() {
		return addTime;
	}
	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}
	public String getCertificate() {
		return certificate;
	}
	public void setCertificate(String certificate) {
		this.certificate = certificate;
	}
	public TraConfine getConfine() {
		return confine;
	}
	public void setConfine(TraConfine confine) {
		this.confine = confine;
	}
	public BigDecimal getRemitRate() {
		return remitRate;
	}
	public void setRemitRate(BigDecimal remitRate) {
		this.remitRate = remitRate;
	}
	public BigDecimal getRemitFee() {
		return remitFee;
	}
	public void setRemitFee(BigDecimal remitFee) {
		this.remitFee = remitFee;
	}
	public String getPayTmsl() {
		return payTmsl;
	}
	public void setPayTmsl(String payTmsl) {
		this.payTmsl = payTmsl;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public Agent getAgent() {
		return agent;
	}
	public void setAgent(Agent agent) {
		this.agent = agent;
	}
	public String getTransCode() {
		return transCode;
	}
	public void setTransCode(String transCode) {
		this.transCode = transCode;
	}
}
